<template>
  <div class="wrapper">
    <div class="wrap">
      <el-form ref="form" :model="form" label-width="1px" :rules="rules">
        <div class="title">Login</div>
        <el-form-item label="" prop="username">
          <el-input v-model="form.username" placeholder="手机号"></el-input>
        </el-form-item>
        <el-form-item label="" prop="password">
          <el-input
            v-model="form.password"
            placeholder="密码"
            type="password"
          ></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="Login" class="btn-lg"
            >立即登录</el-button
          >
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<script>
import Identify from "@/components/Identify.vue";
export default {
  components: { Identify },
  data() {
    return {
      form: {
        username: "",
        password: "",
      },
      rules: {
        username: [
          { required: true, trigger: "blur", message: "手机号不能为空" },
        ],
        password: [
          { required: true, trigger: "blur", message: "密码不能为空" },
        ],
      },
    };
  },
  mounted() {},
  methods: {
    Login() {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          this.$store.dispatch("login", this.form).then(() => {
            this.$router.push({
              path: this.redirect || "/home",
              query: this.otherQuery,
            });
          }).catch(error=>{
            this.$message({
          message: error,
          type: 'warning',
          duration:5000
        });
          });
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
  },
};
</script>
<style lang="scss" scoped>
.wrapper {
  width: 100%;
  height: calc(100vh - 320px);
  background: url("../assets/images/login-01.jpg") no-repeat;
  background-size: 100% auto;
  &::after {
    clear: both;
    display: block;
    content: "";
    height: 0;
  }
  .wrap {
    position: absolute;
    width: 500px;
    background: #fff;
    top: 60px;
    right: 100px;
    min-height: 450px;
    .el-form {
      width: 400px;
      margin: 0 auto;
      margin-top: 80px;
    }
    .title {
      width: 100%;
      font-size: 28px;
      font-weight: 600;
      text-align: center;
      padding-bottom: 22px;
    }
  }
}
</style>
